%% copy riak-0.14.2 source to learn dynamo implementation and erlang
%% author: lichuang
-module(edynamo_core).
-export([stop/0, stop/1]).
-export([register_vnode_module/1, vnode_modules/0]).

stop() -> stop("edynamo stop requested").
stop(Reason) ->
  error_logger:info_msg(io_lib:format("~p~n",[Reason])),
  init:stop().

vnode_modules() ->
  case application:get_env(edynamo_core, vnode_modules) of
    undefined -> [];
    {ok, Mods} -> Mods
  end.

register_vnode_module(VNodeMod) when is_atom(VNodeMod) ->
  case application:get_env(edynamo_core, vnode_modules) of
    undefined ->
      application:set_env(edynamo_core, vnode_modules, [VNodeMod]);
    {ok, Mods} ->
      application:set_env(edynamo_core, vnode_modules, [VNodeMod | Mods])
  end,
  edynamo_ring_events:force_sync_update().
